package com.sport.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.sport.utils.StringListDeserializer;
import org.junit.Test;


import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.assertEquals;


public class StringListDeserializerTest {

    @Test
    public void testDeserialize() throws Exception {
        ObjectMapper mapper = new ObjectMapper();
        SimpleModule module = new SimpleModule();
        module.addDeserializer(List.class, new StringListDeserializer());
        mapper.registerModule(module);

        String jsonString = "[\"共育品规\", \"重点品规\", \"高端卷烟\"]";
        List<String> result = mapper.readValue(jsonString, List.class);

        assertEquals(Arrays.asList("共育品规", "重点品规", "高端卷烟"), result);
    }
}

